import request from '@/utils/request.js'

/**
 * 菜单接口
 *
 * @method getMenuNav 获取菜单导航
 * @method getList 获取菜单列表
 * @method save 保存菜单
 * @method update 修改菜单
 * @method remove 删除菜单
 */
export function useMenuApi() {
  const basePath = '/admin/menu'

  const getMenuNav = () => {
    return request({
      url: `${basePath}/nav`,
      method: 'get'
    })
  }

  const getList = (data) => {
    return request({
      url: `${basePath}/list`,
      method: 'post',
      data
    })
  }

  const save = (data) => {
    return request({
      url: `${basePath}/save`,
      method: 'post',
      data
    })
  }

  const update = (data) => {
    return request({
      url: `${basePath}/update`,
      method: 'put',
      data
    })
  }

  const remove = (data) => {
    return request({
      url: `${basePath}/delete`,
      method: 'delete',
      data
    })
  }
  return {
    getMenuNav,
    getList,
    save,
    update,
    remove
  }
}
